1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation version 2.1 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  */
20 
21 /**
22  * @file desc_event_extended.h
23  * @ingroup descriptors
24  * @brief Provides the descriptors for the extended event descriptor
25  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
26  * @author Mauro Carvalho Chehab
27  * @author Andre Roth
28  *
29  * @par Relevant specs
30  * The descriptor described herein is defined at:
31  * - ETSI EN 300 468 V1.11.1
32  *
33  * @par Bug Report
34  * Please submit bug reports and patches to linux-media@vger.kernel.org
35  */
36 
37 module libdvbv5_d.desc_event_extended;
38 
39 import libdvbv5_d.descriptors: dvb_desc;
40 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms;
41 
42 extern (C):
43 
44 /**
45  * @struct dvb_desc_event_extended
46  * @ingroup descriptors
47  * @brief Structure containing the extended event descriptor
48  *
49  * @param type			descriptor tag
50  * @param length		descriptor length
51  * @param next			pointer to struct dvb_desc
52  * @param id			descriptor number
53  * @param last_id		last descriptor number
54  * @param language		ISO 639 language code
55  * @param text			text string
56  * @param text_emph		text emphasis string
57  *
58  * @details
59  * The emphasis text is the one that uses asterisks. For example, in the text:
60  *	"the quick *fox* jumps over the lazy table" the emphasis would be "fox".
61  */
62 struct dvb_desc_event_extended
63 {
64     align (1):
65 
66     ubyte type;
67     ubyte length;
68     dvb_desc* next;
69 
70     union
71     {
72         align (1):
73 
74         struct
75         {
76             import std.bitmanip : bitfields;
77             align (1):
78 
79             mixin(bitfields!(
80                 ubyte, "last_id", 4,
81                 ubyte, "id", 4));
82         }
83 
84         ubyte ids;
85     }
86 
87     ubyte[4] language;
88     char* text;
89     char* text_emph;
90 }
91 
92 // struct dvb_v5_fe_parms;
93 
94 /**
95  * @brief Initializes and parses the extended event descriptor
96  * @ingroup descriptors
97  *
98  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
99  * @param buf	buffer containing the descriptor's raw data
100  * @param desc	pointer to struct dvb_desc to be allocated and filled
101  *
102  * This function allocates a the descriptor and fills the fields inside
103  * the struct. It also makes sure that all fields will follow the CPU
104  * endianness. Due to that, the content of the buffer may change.
105  *
106  * @return On success, it returns the size of the allocated struct.
107  *	   A negative value indicates an error.
108  */
109 int dvb_desc_event_extended_init (
110     dvb_v5_fe_parms* parms,
111     const(ubyte)* buf,
112     dvb_desc* desc);
113 
114 /**
115  * @brief Prints the content of the extended event descriptor
116  * @ingroup descriptors
117  *
118  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
119  * @param desc	pointer to struct dvb_desc
120  */
121 void dvb_desc_event_extended_print (
122     dvb_v5_fe_parms* parms,
123     const(dvb_desc)* desc);
124 
125 /**
126  * @brief Frees all data allocated by the extended event descriptor
127  * @ingroup descriptors
128  *
129  * @param desc pointer to struct dvb_desc to be freed
130  */
131 void dvb_desc_event_extended_free (dvb_desc* desc);